package com.sky.mapper;

import com.sky.aop.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 分类分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    List<Category> selectByPage(CategoryPageQueryDTO categoryPageQueryDTO);


    /**
     * 分类新增功能
     * @param category
     * @return
     */
    @Insert("insert into category (type, name, sort, status, create_time, update_time, create_user, update_user) values " +
            "(#{type}, #{name}, #{sort}, #{status}, #{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(OperationType.INSERT)
    Integer insertCategory(Category category);


    /**
     * 更新表信息
     * @param category
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    Integer updateById(Category category);

    /**
     * 根据id删除分类
     * @param id
     * @return
     */
    @Delete("delete from category where id = #{id}")
    Integer deleteById(Long id);

    /**
     * 根据类型查询分类
     * @param type
     * @return
     */
//    @Select("select * from category where type = #{type} order by sort asc,create_time desc")
    List<Category> selectByType(Integer type);


}
